@extends("Admin.layout.layout")
@section("title","增加话题")
@section("con")
<div class = "row">
	<div class = "col-md-6 col-md-offset-3" >
		<form action = "/admin/topic/insert" id = "form" method = "post" enctype= "multipart/form-data">
			<select class="form-control" name = "pid" onchange = "showorhidden()">
					<option value = "0">顶级话题</option>
					@foreach($res as $key=>$value)
					@if($value->pid!=0)
						<option value = "{{$value->id}}" disabled="disabled">{{$value->topic_name}}</option>
					@else
						<option value = "{{$value->id}}" @if($fid == $value->id)selected @endif>{{$value->topic_name}}</option>
					@endif
				    @endforeach
			</select>
			<br />
			<input class="form-control" placeholder="子话题" type = "text" name = "topic_name">
			</br>
			<div id = "desc" style = "display:none">
				<textarea class="form-control" placeholder="话题描述" type = "text" name = "topic_summary"></textarea>
				</br>
			</div>
			<div id = "desc1" style = "display:none">
				话题图标:
				<input type = "file"  name = "topic_portrait" id = "topic_portrait"/>
				<div id = "preview"></div>
			</div>
			{{csrf_field()}}
			<div class = "col-md-offset-5">
				<button type="submit" id = "button" class="btn btn-success">增加话题</button>
			</div>
		</form>
	</div>
</div>
<script>
	function showorhidden()
	{
		var value = document.getElementsByTagName("select")[0].value;
		if(value == 0)
		{
			document.getElementById("desc").style.display = "none";
			document.getElementById("desc1").style.display = "none";
		}
		else
		{
			document.getElementById("desc").style.display = "block";
			document.getElementById("desc1").style.display = "block";
		}
	}
	var value = document.getElementsByTagName("select")[0].value;
		if(value == 0)
		{
			document.getElementById("desc").style.display = "none";
			document.getElementById("desc1").style.display = "none";
		}
		else
		{
			document.getElementById("desc").style.display = "block";
			document.getElementById("desc1").style.display = "block";
		}
</script>
@endsection